home *** CD-ROM | disk | FTP | other *** search
/ Gigarom 1 / Gigarom Macintosh Archives (Quantum Leap)(CDRM1080320)(1993).iso / FILES / HYP / H-I / HypertalkTools.cpt / HyperTalk Sampler 1.1 / card_3853.txt < prev    next >
Text File  |  1989-02-26  |  3KB  |  77 lines

  1. -- card: 3853 from stack: in.1
  2. -- bmap block id: 0
  3. -- flags: 0000
  4. -- background id: 2619
  5. -- name: 
  6. ----- HyperTalk script -----
  7.  
  8.  
  9.  
  10.  
  11. -- part 2 (button)
  12. -- low flags: 00
  13. -- high flags: 0000
  14. -- rect: left=43 top=26 right=62 bottom=77
  15. -- title width / last selected line: 0
  16. -- icon id / first selected line: 32462 / 32462
  17. -- text alignment: 1
  18. -- font id: 0
  19. -- text size: 12
  20. -- style flags: 0
  21. -- line height: 16
  22. -- part name: New Button
  23. ----- HyperTalk script -----
  24. on mouseUp
  25.   play "Boing" tempo 120 a
  26.   push card
  27.   visual zoom open
  28.   go to card id 16769 of stack "Help"
  29. end mouseUp
  30.  
  31.  
  32.  
  33. -- part contents for background part 6
  34. ----- text -----
  35. Message Handlers
  36.  
  37. -- part contents for background part 10
  38. ----- text -----
  39. A script may have one or more Message Handlers.  Inside the Message Handler are the instructions for HyperCard to perform if that message is sent.  
  40. "MouseUp" is a message that is sent when the mouse button is let up.  "MouseDown" is a message that is sent when the mouse is pressed down.  
  41.  
  42. If you click on a button, the message "mouseDown" is sent to that button.  If you let the mouse up while still on the button, the message "mouseUp" is sent to that button. If you drag off the button before letting the mouse up, the "mouseUp" message will NOT be sent to the button.  This allows you the opportunity to change your mind, and is why most button scripts use only 
  43. "mouseUp" handlers.
  44.  
  45. Try clicking the Test Button, waiting a second, then letting the mouse button up.  Then try clicking the Test Button, dragging off of it while still holding the mouse button down, then let it up.
  46.  
  47. A message handler always begins with the word "on" and is followed by the name of the message.  After the instructions for the handler, you must close the handler with the word "end" followed by the name of the handler.
  48.  
  49. There are many messages that you can make handlers for.  The computer sends these messages whenever you do something like go to a card, leave a card, start typing in a field, etc.  The computer sends some messages only to buttons, some only to fields, and some only to cards.  These messages give you a lot of power to program HyperCard.  For simplicity in this tutorial, we will only be concerned with messages that are sent to buttons.
  50.  
  51. Are you ready to make your own handler?  You will mostly use the two handlers shown in the Script Window when programming your buttons.  But if you want to try an interesting one, there is a message the computer sends if the mouse merely enters the area of the button, without even clicking.  It's called 
  52. "mouseEnter".  Try making  your own handler to play 
  53. "boing" if the mouse is moved over the Test Button.  Then test it by clicking "Send To Button" and moving the mouse over the Test Button.
  54.  
  55. Click ? to find out more about "Message Handlers".
  56.  
  57. -- part contents for background part 9
  58. ----- text -----
  59. on mouseDown
  60.   play "harpsichord"
  61. end mouseDown
  62.  
  63. on mouseUp
  64.   play "boing"
  65. end mouseUp
  66.   
  67.  
  68. -- part contents for background part 13
  69. ----- text -----
  70. on mouseDown
  71.   play "harpsichord"
  72. end mouseDown
  73.  
  74. on mouseUp
  75.   play "boing"
  76. end mouseUp
  77.